# -*- coding:utf-8 -*-
__author__ = 'xigu007'
from kivy.metrics import dp, sp
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty,ListProperty
from kivy.lang import Builder
from composite_widget.base import RelativeComposite,Division
from composite_widget.content import LabelContent, ImageContent, ShapeContent
from composite_widget.group import ShapeBackground

Builder.load_string('''
<Example1>
    #设置为白色背景
    canvas.before:
        Color:
            rgb: 1,1,1
        Rectangle:
            pos: 0,0
            size: self.size
    Division:
        #设置DIV宽度200
        absolute_width: dp(200)
        ImageContent:
            source: 'res/flower.jpg'
            #设置图片高为div的0.8
            size_hint: None, 0.8
    Division:
        orientation: 'vertical'
        Division:
            #内容停靠排版
            contents_typesetting: 'anchor'
            LabelContent:
                text: '阳光花卉'
                color: 0.2, 0.2, 0.2, 1
                font_size: sp(20)
                #停靠左边
                anchor: 'left'
                #content下对齐DIV
                align: 'bottom'
            LabelContent:
                text: '1.4km'
                color: 0.6, 0.6, 0.6, 1
                font_size: sp(16)
                margin: 0,20,0,0
                anchor: 'right'
        Division:
            #Div高度正好包裹内容,即等于内容高度
            wrap_content_height: True
            contents_typesetting: 'anchor'
            LabelContent:
                text: '[2704店通用]阳光花卉11朵红玫瑰加4朵百合'
                color: 0.6, 0.6, 0.6, 1
                font_size: sp(16)
                #文字宽度为DIV的0.8
                text_width_hint: 0.8
                margin: 0,0,8,8
                anchor: 'left'
        Division:
            contents_typesetting: 'anchor'
            LabelContent:
                text: '￥126'
                color: 1.0, 0.357, 0.141, 1
                font_size: sp(22)
                margin: 0,4,0,0
                anchor: 'left'
                align: 'top'
            LabelContent:
                text: '￥375'
                color: 0.6, 0.6, 0.6, 1
                font_size: sp(16)
                margin: 4,16,0,0
                anchor: 'left'
                align: 'bottom'
            ShapeBackground:
                color: 1.0, 0.357, 0.141, 1
                radius: 3
                solid: False
                anchor: 'left'
                margin: 10,0,0,0
                LabelContent:
                    margin: 8,8,2,2
                    color: 1.0, 0.357, 0.141, 1
                    text: '减2元'
''')

class Example1(RelativeComposite):
    pass
